<?
	include("../includes/main_inc.php");


?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Affiliate Bubble Administration</title>

<link href="../../css/admin.css" rel="stylesheet" type="text/css">
<script src="../../jscript/menuArray.php" language="javascript"></script>
<script src="../../jscript/clock.js" language="javascript"></script>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style></head>

<body onLoad="funClock();">
<?php include("../includes/header.php"); ?>
<table width="100%" border="0" cellspacing="25" cellpadding="0">
<tr>
<td valign="top" width="240"><div id="menu"></div></td>
<td valign="top" align="center">

<div id="content">

<table width="600" border="0" cellpadding="5" cellspacing="1" bgcolor="#E9EEF5">
<tr id="formHeader">
<td><strong>Affiliate Statistics </strong></td>
<td align="center"><strong>Today</strong></td>
<td align="center"><strong>Month</strong></td>
<td align="center"><strong>Year</strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Impressions</td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM visits WHERE DAY(visit_date)=DAY(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM visits WHERE MONTH(visit_date)=MONTH(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM visits WHERE YEAR(visit_date)=YEAR(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Revenue Raised </td>
<td align="center" bgcolor="#FFFFFF">$  
  <?
	$SQL="SELECT SUM(SaleAmount) FROM affiliateEarn WHERE  DAY(EDateTime)=DAY(NOW())";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],2);
?></td>
<td align="center" bgcolor="#FFFFFF">$
  <?
	$SQL="SELECT SUM(SaleAmount) FROM affiliateEarn WHERE  MONTH(EDateTime)=MONTH(NOW())";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],2);
?></td>
<td align="center" bgcolor="#FFFFFF">$
  <?
	$SQL="SELECT SUM(SaleAmount) FROM affiliateEarn WHERE  YEAR(EDateTime)=YEAR(NOW())";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],2);
?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Affiliate  Commissions </td>
<td align="center" bgcolor="#FFFFFF">$ <?
	$SQL="SELECT SUM(CommissionAmount) FROM affiliateEarn WHERE DAY(EDateTime)=DAY(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF">$ <?
	$SQL="SELECT SUM(CommissionAmount) FROM affiliateEarn WHERE MONTH(EDateTime)=MONTH(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF">$ <?
	$SQL="SELECT SUM(CommissionAmount) FROM affiliateEarn WHERE YEAR(EDateTime)=YEAR(NOW())";
	//print $SQL;
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Affiliate Sales </td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE DAY(EDateTime)=DAY(NOW()) AND EType='Sale'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE MONTH(EDateTime)=MONTH(NOW()) AND EType='Sale'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE YEAR(EDateTime)=YEAR(NOW()) AND EType='Sale'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print $data[0];
?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Affiliate Leads </td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE DAY(EDateTime)=DAY(NOW()) AND EType='Lead'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE MONTH(EDateTime)=MONTH(NOW()) AND EType='Lead'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE YEAR(EDateTime)=YEAR(NOW()) AND EType='Lead'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">Affiliate Clicks </td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE DAY(EDateTime)=DAY(NOW()) AND EType='Click'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE MONTH(EDateTime)=MONTH(NOW()) AND EType='Click'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
<td align="center" bgcolor="#FFFFFF"><?
	$SQL="SELECT COUNT(*) FROM affiliateEarn WHERE YEAR(EDateTime)=YEAR(NOW()) AND EType='Click'";
	$rslt=$r->RawQuery($SQL);
	$data=mysql_fetch_array($rslt);
	print number_format($data[0],0);
?></td>
</tr>
</table>

</div>

</td>
</tr>
</table>
</body>
</html>
